<?php

$texto = file_get_contents('nuestra-carta');

preg_match_all('/\<div\sclass\=\"titulo-producto-cuerpo\"\>([^\>]*)\<\/div\>/', $texto, $matches);
$m = $matches[1];
$products = array();
foreach($m as $key => $value) {
	$value = $m[$key] = trim($value);
	if (preg_match("/^\d+.*/", $value) != 1) {
		unset($m[$key]);
		continue;
	}
	preg_match('/(\d+)\.\s*(.*)/', $value, $matches);
	$products[$matches[1]] = $matches[2];
echo "    	 products.add(generateProduct({$matches[1]}, \"{$matches[2]}\"));\n";

}

/*
$products = array_reverse($products);

preg_match_all('/\<img[^>]*class=\"imagecache\simagecache-preset_productos_listado_cuadricula\simagecache-default\simagecache-preset_productos_listado_cuadricula_default\"[^>]*>/', $texto, $matches);
foreach($matches[0] as $key => $value) {
	preg_match('/src="(.*\d+[_0]?.png)"/', $value, $match);
	if (isset($match[1]))
	echo "wget " .$match[1] . "\n";
}
*/
